<?php

function in_permission($id,$arr){
	foreach ($arr as $k => $v) {
		if($v->id==$id){
			return true;
		}
	}
	return false;
}

function make_tree($list,$pk='id',$cid='cid',$child='_child',$root=0){  
    $tree=array();   
    $packData=array();  
    foreach ($list as  $data) {  
        $packData[$data[$pk]] = $data; //$packData[1]=$data; $packData[2]=$data   
    }  
    foreach ($packData as $key =>$val){       
        if($val[$cid]==$root){   //代表跟节点         
            $tree[]=& $packData[$key];  
        }else{  
            //找到其父类  
            $packData[$val[$cid]][$child][]=& $packData[$key];  
        }  
    }  
    return $tree;  
}  
function in($urlPath,$arr){
        if(isset($arr['_child'])){
            foreach ($arr['_child'] as $k => $v) {
                if($v['name']==$urlPath){
                    return true;
                }elseif(isset($v['_child'])){

                    $this->in($urlPath,$v['_child']);
                }
            }
            return false;
        }
    }
